<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title>宿舍评比</title>
		<link rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
		<script type='text/javascript' src='../js/sorttable.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/apartmentViewAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
		<script type="text/javascript">			        
	        var gaptInfo=""; //这个gaptInfo是全局变量 
	        var apartmentid;
		        
			function setApartList() {
				 apartmentViewAction.getAllApartInfo(mycallback);
			}
			
			var mycallback = function setList(aptValue)//回调函数
			{
					gaptInfo =aptValue;
					var s = $("apartmentid");
				 	DWRUtil.removeAllOptions(s); 
					s.options[0] = new Option("请选择公寓",'0');
				for ( var i = 1; i < aptValue.length+1; i++) {
					var opt = new Option(aptValue[i-1].apartmentname,aptValue[i-1].apartmentid);
					s.options[i] = opt;
				}
			}
			function checkOnSubmit(){
				var file=document.getElementById("uploadFile");
				if(''==file.value){
					alert("请选择上传文件！！");
					return false;
				}else{
					var progressBar=document.getElementById("div_ProgressBar");
					progressBar.style.visibility="visible";
					return true;
				}
			}
			function submitDormitory(){
				if($('apartmentid').selectedIndex == 0){
					alert("请选择公寓!");
					return false;
				}
				else return true;
			}
		</script>
	<body onload="javascript:setApartList()">
		<div id="page_container">
			<%@include file="mgrbanner.jsp"%>
			<h2>
				生成宿舍评分模版
			</h2>
			<div>
				<form action="aptmgr/exportdormrateexcel.action" method="post"
					id="formForGenExcel" onsubmit="return submitDormitory()">
					<table align="center">
						<tr>
							<td>
								<select class="common_select" name="apartmentid"
									id="apartmentid" style="width: 120"></select>
							</td>
							<td>
								<input class="common_button" type="submit" value="提交" />
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div>
				<h2>
					上传宿舍评分结果
				</h2>
				<s:form action="upload/uploadDormRatingResult.action" method="post"
					enctype="multipart/form-data" theme="simple" onsubmit="return checkOnSubmit();">
					<table class="table_common" width="600px">
						<!-- 
					<tr>
						<td  class="td_left" style="width:20%">
							文件标题：
						</td>
						<td  class="td_right" style="width:80%">
							<s:textfield name="title"></s:textfield>（可选）
						</td>
					</tr>
				 	-->
						<tr>
							<td class="td_left">
								选择Excel文件：
							</td>
							<td class="td_right">
								<s:file name="uploadedFile" id="uploadFile"></s:file>
							</td>
						</tr>
					</table>
					<s:submit cssClass="common_button" value="上传"></s:submit>
				</s:form>
				<div id="div_ProgressBar">
				<img id="progressBar"
					src="<%=request.getContextPath()%>/images/progress2.gif">
				<br>
				<span>文件上传中,请稍候...</span>
			</div>
			</div>
		</div>
	</body>
</html>